e
#Title[BuƂBpt̒v]
#Text[eIE퉻w
BuƂBpt̒v]
#BackGround[User]
#BGM[.\..\bgm\bgm.wav]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
	
	////////////////////////////////////////////////////////////////////////
	//                                                          //
	//   `Ԃ̑Sʒeway炵                              //
	////////////////////////////////////////////////////////////////////////
	
	@Initialize{
		InitializeData();
		
		LoadUserShotData(shot_ryoyan);
		
		SetLife(1000);
		SetDamageRate(10,0);
		SetInvincibility(240);
		SetEnemyMarker(true);
		SetEffectForZeroLife(180,170,1);
		
		move02(GetCenterX(),GetCenterY(),0,0,0,0);
		
		TMain();
	}
	
	@MainLoop{
		yield;
	}
	
	@DrawLoop{
		DrawBoss(imgBoss);
	}
	
	@Finalize{
		FinalizeData();
	}
	
	task TMain(){
		wait(60);
		
		DeclareSpell();
		
		SetCollisionEx(300,30);
		
		Atack();
		Move();
		BombBarrier();
	}
	
	function DeclareSpell(){
		SetTimer(150);
		CutIn(YOUMU,"BuƂBpt̒v",NULL,0,0,0,0);
		SetScore(1000000);
		wait(180);
	}
	
	task Atack(){
		let count=0;
		let ang=0;

		// `
		LaserSwing(_RED14());
		breeeeak();
		ang=GetAngleToPlayer()+45;
		while(GetTimer()>120 && GetEnemyLife()>800) {
			ang+=0.5+sin(count*2)*1;
			CreateShotA(0,GetX()+rand(-10,10),GetY()+rand(-10,10),30);
			SetShotDataA(0,0,0,0,0,0,0,_RED01());
			SetShotKillTime(0,0);
			FireShot(0);
			ascent(i in 0..4) {
				let ang2=ang+i*90;
				let x=GetX()+cos(ang2)*180;
				let y=GetY()+sin(ang2)*180;
				let id=CreateShotObj(x,y,2,ang2-180,_RED01L(),30);
				AA_TimeDelete(id,180/2+30,false);
			}
			if(count%120==60) {
				let tm=GetAngleToPlayer();
				ascent(i in -20..21) {
					let spd=2+(20-absolute(i))/5;
					CreateShot02(GetX(),GetY(),0,tm+i*1.5,0.01*spd,spd,_RED02L(),0);
				}
				//playSE(2);
			}
			//playSE(1);
			count++;
			yield;
		}
		DeleteEnemyShotToItem(ALL);

		// `
		LaserSwing(_WHITE14());
		breeeeak();
		ang=GetAngleToPlayer()+180;
		while(GetTimer()>90 && GetEnemyLife()>600) {
			CreateShotA(0,GetX()+rand(-10,10),GetY()+rand(-10,10),30);
			SetShotDataA(0,0,0,0,0,0,0,_WHITE01());
			SetShotKillTime(0,0);
			FireShot(0);
			CreateShotObj(GetX()+rand(-10,10),GetY()+rand(-10,10),rand(1,2),ang+rand(-5,5),_WHITE01L(),20);
			//playSE(1);
			if(count%90==45) {
				let ang2=rand(0,360);
				ascent(i in 0..24){
					let x=GetX()+cos(ang2)*180;
					let y=GetY()+sin(ang2)*180;
					let id=CreateShotObj(x,y,1,ang2-180,_WHITE05(),20);
					AA_TimeDelete(id,180+20,false);
					ang2+=360 / 24;
				}
			}
			ang+=1.2;
			count++;
			yield;
		}
		DeleteEnemyShotToItem(ALL);

		// O`
		LaserSwing(_AQUA03());
		breeeeak();
		ang=0;
		count=0;
		while(GetTimer()>60 && GetEnemyLife()>400) {
			CreateShotA(0,GetX()+rand(-10,10),GetY()+rand(-10,10),30);
			SetShotDataA(0,0,0,0,0,0,0,_BLUE01());
			SetShotKillTime(0,0);
			FireShot(0);
			let x=GetX()+cos(ang)*180;
			let y=GetY()+sin(ang)*180;
			let id=CreateShot01(x,y,1.5,ang-180,_BLUE43(),30);
			AA_TimeDelete(id,150,false);
			//playSE(1);
			ang+=1+sin(count*2.2)*0.6-60;
			count++;
			yield;
		}
		DeleteEnemyShotToItem(ALL);

		// l`
		LaserSwing(_GREEN21L());
		breeeeak();
		count=0;
		while(GetTimer()>30 && GetEnemyLife()>200) {
			if(count%200<120) {
				ang=count*222.5;
				CreateShotA(0,GetX()+rand(-10,10),GetY()+rand(-10,10),30);
				SetShotDataA(0,0,0,0,0,0,0,_GREEN01());
				SetShotKillTime(0,0);
				FireShot(0);
				CreateShot01(GetX(),GetY(),3-(count%200/200)*3,ang,_GREEN12(),30);
				//playSE(1);
			}
			else {
				if(count%200==120) {
					ang=GetAngleToPlayer();
					ascent(i in 0..8) {
						let id=CreateLaserObjA(GetX(),GetY(),ang+i*45,250,90,_RED21L(),50,false);
						AA_TimeDelete(id,90,true);
					}
					//playSE(2);
				}
			}
			count++;
			yield;
		}
		DeleteEnemyShotToItem(ALL);

		// Xg
		SetShotAutoDeleteClip(300,300,300,300);
		breeeeak();
		count=0;
		while(GetTimer()>0 && GetEnemyLife()>0) {
			ang=-count*count*0.05+rand(-5,5);
			ascent(i in 0..2) {
				let ang2=ang+i*180;
				let x=GetX()+cos(ang2)*300;
				let y=GetY()+sin(ang2)*300;
				let id=CreateShotObj(x,y,2,ang2-180,_WHITE01(),0);
				AA_TimeDelete(id,150,false);
			}
			count++;
			//playSE(1);
			yield;
		}
		DeleteEnemyShotToItem(ALL);

		//playSE(0);
		CreateShot02(GetX(),GetY(),0,GetAngleToPlayer(),0.05,9,_YELLOW01L(),60);
	}
	
	function LaserSwing(let gp) {
		ascent(i in 0..20) {
			let ang=i*18;
			let sw=0.2*p1m0(i);
			CreateLaserB(0,300,30,gp,100);
			SetLaserDataB(0,0,0,0,1.7,ang,sw,ang,sw);
			SetLaserDataB(0,100,0,NULL,0,NULL,sw,NULL,sw);
			FireShot(0);
		}
	}

	function breeeeak() {
		//playSE(0);
		PlaySE(se_charge);
		SetInvincibility(100);
		Concentration01(100);
		wait(100);
	}
	
	task Move(){
	}
	
	task BombBarrier(){
		loop{
			if( OnBomb ){
				SetInvincibility(2);
			}
			
			yield;
		}
	}
	
	#include_function ".\..\functions\initialize.txt"
	#include_function ".\..\functions\color_set.txt"
	#include_function ".\..\functions\function.txt"
}
